﻿@model Sykj.Entity.Users
@{
    ViewData["Title"] = "编辑用户";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
@section scriptstop
    {
    <link href="~/layuiadmin/formSelects-v4.css" rel="stylesheet" />
}
<div class="layui-bgn" style="padding-bottom:50px;">
    <form class="layui-form" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">请选择角色</label>
            <div class="layui-input-block">
                <select xm-select="RoleIds" asp-for="RoleIds" asp-items="@ViewBag.RolesList"></select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" asp-for="UserName" lay-verify="title" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名</label>
            <div class="layui-input-block">
                <input type="text" asp-for="TrueName" lay-verify="title" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" asp-for="NickName" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Phone" lay-verify="title" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Email" lay-verify="title" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" asp-for="Activity" lay-skin="switch" lay-filter="activity">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit" id="submit" type="button">提交</button>
                <button id="close" type="button" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
        <input type="hidden" asp-for="UserId" />
    </form>
</div>
    @section scriptsfeet
        {
        <script type="text/javascript">
    layui.config({
        base: '/layuiadmin/'
    }).extend({
        formSelects: 'formSelects-v4'
    }).use(['form', 'formSelects', 'layer', 'sykjwh'], function () {
        var $ = layui.$,
            form = layui.form,
            formSelects = layui.formSelects,
            sykjwh = layui.sykjwh;

        $("#close").click(function () {
            sykjwh.close();
        });

        form.on('submit(edit)', function (obj) {
            //以数组获取所选角色ID集合
            obj.field.RoleIds = formSelects.value('RoleIds', 'val');
            obj.field.Activity = $("#Activity").val();
            //保存
            sykjwh.save('@Url.Action("edit", "users", new { area = Constant.AREAMANAGER })', obj.field);
        });

        //监听checkbox
        form.on('switch(activity)', function (data) {
            this.value = data.elem.checked;
        });
    });
        </script>
    }
